package com.cat.task;

import com.cat.service.AnalyzeService;
import com.cat.service.DisplayService;
import com.cat.service.DownloadService;
import com.cat.service.SpiderService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * ？
 *
 * @author xiemh
 * @date 2018/12/14 9:01
 * @since v1.0.0
 */
@Component
public class CatCron {
    // private static final Logger logger = LoggerFactory.getLogger(FirstCron.class);

    @Resource SpiderService spiderService;
    @Resource DownloadService downloadService;
    @Resource DisplayService displayService;
    @Resource AnalyzeService analyzeService;

//    @Scheduled(fixedDelay = 100) //毫秒
    public void scheduledAnalyze() {
        System.out.println("analyze");
        try {
            analyzeService.analyzeImg();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // @Scheduled(cron = "0/5 * * * * ?")
    public void scheduledDemo() {
        // logger.info("定时任务进行中.......");
        // do something else
        System.out.println("task");
    }

//     @Scheduled(cron = "*/5 * * * * ?")
    public void scheduledSpider() {
        System.out.println("Spider");
        spiderService.findImgSourceDO();
    }

    // @Scheduled(cron = "0/5 * * * * ?")
    public void scheduledDownload() {
        System.out.println("Download");
        downloadService.downloadImgSourceDO();
    }

    public void scheduledDisplay() {
        System.out.println("Display");
        // displayService
    }
}
